<template>
  <el-dialog :visible.sync="visible" v-dialogDrag :title="title" :close-on-click-modal="false" class="tl-dialog" width="1200px" @open="open" @close="close">
    <el-form class="tl-form" ref="form" :model="model" :rules="rules" label-width="150px" :disabled="disableEditSubmit">
			<el-row>
				<el-col :span="12" v-if="bpaSystemFlag">
					<el-form-item label="所属业务" prop="belongbusiness" :rules="rules.validateRequire">
            <el-select v-model="model.belongbusiness"  placeholder="请选择所属业务" filterable clearable @change="setBelongBusiness">
              <el-option v-for="item in codeModel.businessTypeList" :key="item.code" :label="item.name" :value="item.code"/>
            </el-select>
          </el-form-item>
				</el-col>
        <el-col :span="12" v-else>
					<el-form-item label="业务类型" prop="servicetype" :rules="rules.validateRequire" >
            <el-select v-model="serviceTypes" multiple placeholder="请选择业务类型" filterable clearable @change="setServiceType">
              <el-option v-for="item in codeModel.feedbackServiceTypeList" :key="item.code" :label="item.name" :value="item.code"/>
            </el-select>
          </el-form-item>
				</el-col>
				<el-col :span="12">
					<el-form-item label="所属系统" v-if="!bpaSystemFlag" prop="system" :rules="rules.validateRequire">
            <el-select v-model="model.system" placeholder="请选择所属系统" filterable clearable>
              <el-option v-for="item in codeModel.feedbackSystemList" :key="item.code" :label="item.name" :value="item.code"/>
            </el-select>
          </el-form-item>
				</el-col>
<!--			</el-row>-->
<!--			<el-row>-->
				<el-col :span="12">
          <el-form-item label="反馈类型" prop="feedbacktype" :rules="rules.validateRequire">
            <el-select v-model="feedbackTypes" multiple @focus='filterItem' placeholder="请选择反馈类型" filterable clearable @change="setFeedbackType">
              <el-option v-for="item in codeModel.feedbackTypeList" :key="item.code" :label="item.name" :value="item.code"/>
            </el-select>
					</el-form-item>
				</el-col>
				<el-col :span="12">
					<el-form-item label="负责人姓名" prop="systemresponsiblename" :rules="rules.validateRequire">
            <tl-ref-user v-model="model.systemresponsiblename" dataType="code" :initDisplayData.sync="model.systemresponsiblename" :singleSelect="true" @confirm="getDealPerson"></tl-ref-user>
					</el-form-item>
				</el-col>
<!--			</el-row>-->
<!--			<el-row>-->
				<el-col :span="12">
					<el-form-item label="负责人工号" prop="systemresponsiblename" :rules="rules.validateRequire">
						<el-input v-model="model.systemresponsiblecode" :disabled="true"></el-input>
					</el-form-item>
				</el-col>
				<el-col :span="12">
					<el-form-item label="负责人电话" prop="systemresponsibletel" :rules="rules.validateRequire">
						<el-input v-model="model.systemresponsibletel" :disabled="false" clearable></el-input>
					</el-form-item>
				</el-col>
			</el-row>
			<el-row>
				<el-col :span="24">
					<el-form-item label="备注" prop="description" >
						<el-input v-model="model.description" type="textarea" :rows="4"></el-input>
					</el-form-item>
				</el-col>
			</el-row>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button :type="disableEditSubmit === false ? 'text' : 'primary'" @click="doCancelEdit">取消</el-button>
      <el-button type="primary" @click="doSubmitEdit" :loading="saveLoading" v-if="disableEditSubmit === false">确认</el-button>
    </div>
  </el-dialog>
</template>

<script>
/** mixins */
import { mixin_edit } from '@tapui/mixins/mixin_edit'
import { MMS_AREA_LEVEL } from '@/const/const'
import { MMS_FEEDBACK_TYPE } from '@/const/const'
/** 子组件 */
/** 工具类 */
import { putAction, getAction, postAction, deleteAction } from '@tapui/utils/http'
import { MMS_SYSTEM_TYPE } from '@/const/const'
/** VUE配置 */
export default {
  mixins: [mixin_edit],
  components: { },
  data() {
    return {
      moduleTitle: '意见反馈基础配置表',
      urlPrefix: '/mms/baseConfig/',
      url: {
        // 额外的url
        queryCodeList: '/mms/suggestionFeedback/dataCodeList'
      },
      belongBusinesses: [],
      serviceTypes: [],
      feedbackTypes: []
    }
  },
  computed: {
    bpaSystemFlag() {
      return this.$store.getters.microGlobalParam.systemFlag === 'bpa'
    }
  },
  methods: {
   // 过滤掉流程文档没有的反馈类型
    filterItem() {
      if (this.bpaSystemFlag) {
        this.codeModel.feedbackTypeList = this.codeModel.feedbackTypeList.filter(item => item.code === MMS_FEEDBACK_TYPE.processOptimization || item.code === MMS_FEEDBACK_TYPE.processConstruction)
      }
    },

    setBelongBusiness() {
      this.$set(this.model, 'belongbusiness', this.belongbusinesses.join(","))
    },
    setServiceType() {
      this.$set(this.model, 'servicetype', this.serviceTypes.join(","))
    },
    setFeedbackType() {
      this.$set(this.model, 'feedbacktype', this.feedbackTypes.join(","))
    },
    loaded() {
    //  debugger
      // 页面加载完毕执行
      if (this.model.belongbusiness && this.model.belongbusiness !== '') {
        this.belongBusinesses = this.model.belongbusiness.split(',')
      }
      if (this.model.servicetype && this.model.servicetype !== '') {
        this.serviceTypes = this.model.servicetype.split(',')
      }
      if (this.model.feedbacktype && this.model.feedbacktype !== '') {
        this.feedbackTypes = this.model.feedbacktype.split(',')
      }
    },
    // 获取处理人参照
    getDealPerson(selectionRow, selectKey, selectionValue) {
      this.$set(this.model, 'systemresponsiblecode', selectionRow[0].code)
      this.$set(this.model, 'systemresponsiblename', selectionRow[0].name)
      this.$set(this.model, 'systemresponsibletel', selectionRow[0].mobile)
    },
    close() {
      this.model = {}
      this.belongBusinesses = []
      this.serviceTypes = []
      this.feedbackTypes = []
    },
    assignDefaultValue() {
      if (this.bpaSystemFlag) {
        this.$set(this.model, 'system', MMS_SYSTEM_TYPE.cdmc)
      }
		}
  }
}
</script>

